package com.film.rowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.film.domain.Film;
import com.film.domain.Review;
import com.film.domain.User;

public class ReviewRowMapper implements RowMapper<Review>{

	@Override
	public Review mapRow(ResultSet res, int arg1) throws SQLException {
		Review review = new Review();
		review.setRevId(res.getInt("rev_id"));
		review.setRevTime(res.getString("rev_time"));
		review.setRevContent(res.getString("rev_content"));
		review.setRevScore(res.getFloat("rev_score"));
		review.setRevPraise(res.getInt("rev_praise"));
		
		User user = new User();
		user.setuId(res.getInt("u_id"));
		user.setuName(res.getString("u_name"));
		user.setuPassword(res.getString("u_password"));
		user.setuPhoneNum(res.getString("u_phoneNum"));
		user.setuNickName(res.getString("u_nickName"));
		user.setuSex(res.getString("u_sex"));
		user.setuBirthday(res.getString("u_birthday"));
		user.setuLiftState(res.getString("u_life_State"));
		
		user.setuSignature(res.getString("u_signature"));
		user.setuImg(res.getString("u_headImg"));
		review.setUser(user);
		
		Film film = new Film();
		film.setFilmId(res.getInt("film_id"));
		film.setFilmName(res.getString("film_name"));
		film.setFilmForeignName(res.getString("film_foreignName"));
		film.setFilmPlace(res.getString("film_place"));
		film.setFilmTime(res.getString("film_time"));
		film.setFilmShowTime(res.getString("film_showTime"));
		film.setFilmImg(res.getString("film_img"));
		film.setIsDelete(res.getInt("is_delete"));
		film.setBoxoffice(res.getFloat("boxoffice"));
		film.setExpect(res.getInt("expect"));
		film.setFilmIunguage(res.getString("film_lunguage"));
		film.setFilmIntroduce(res.getString("film_introduce"));
		review.setFilm(film);
		return review;
	}

}
